﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Library;
namespace QuanLyThi
{
    public partial class FrmDanhSachHocVien : Form
    {
        public static string mConnect = FrmMain.mConnect;
        private string msql = "";
        public DGC_Library mLibrary = new DGC_Library(mConnect);

        public FrmDanhSachHocVien()
        {
            InitializeComponent();
            this.Load();            
        }
        DataTable dt1 = new DataTable();
        private void button6_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void Load()
        {

            msql = "Select * from tb_Lopdaotao order by ms_lop";
            dt1 = mLibrary.GetDataTable(msql, "table");
            clop.DataSource = dt1;
            clop.DisplayMember = "MS_lop";
            clop.ValueMember = "MS_lop";
            cten.Text = dt1.Rows[clop.SelectedIndex]["tenlop"].ToString();
            clop_SelectionChangeCommitted(null, null);
        }



        private void clop_SelectionChangeCommitted(object sender, EventArgs e)
        {
            cten.Text = dt1.Rows[clop.SelectedIndex]["tenlop"].ToString();
            msql = "Select a.ms_lop,a.ngaydangky,b.MS_HSSV,b.hovaten, " +
                   " case b.gioitinh When 1 then 'Nam' Else N'Nữ' " +
                   " End as Gioitinh, b.namsinh,b.diachi,b.dienthoai,b.mail " +
                   " from tb_hssvlop a inner join tb_hssv b on a.ms_hssv=b.ms_hssv " +
                   " Where a.ms_lop='" + clop.SelectedValue.ToString() + "' Order by b.hovaten";
            DataTable dt2 = mLibrary.GetDataTable(msql, "tb1");
            dataGridView1.AutoGenerateColumns = false;    
            dataGridView1.DataSource = dt2;
                 
        }

   


      

      
    }
}
